package com.lagou.edu.service.impl;

import com.lagou.edu.service.EmailService;
import com.lagou.edu.util.EmailUtil;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

@Service
public class EmailServiceImpl implements EmailService {
    @Value("${config.email.host}")
    private String emailHost;

    @Override
    public Boolean sendEmail(String email, String emailTitle, String message) {

        try {
            //这里邮箱地址和授权码暂时写死，安全性考虑没有放到配置文件中
//            EmailUtil.sendEmail(emailHost, "505907915@qq.com", "DWRHKKPLQOEFXDNR", email, emailTitle, message);

            EmailUtil.sendMail(email, message, emailTitle);
            return true;
        } catch (Exception ex) {
            ex.printStackTrace();
            return false;
        } finally {
        }
    }
}
